﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TireService.Web.View.CustomerView
{
    public partial class EditCustomerData : System.Web.UI.Page
    {
        public int CustomerId
        {
            get
            {
                if (ViewState["_customerid"] != null)
                    return (int)ViewState["_customerid"];
                else
                    return 0;
            }
            set
            {
                ViewState["_customerid"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack != true)
            {
                try
                {
                    this.CustomerId = Convert.ToInt32(Request.QueryString["CustomerId"]);

                    
                    
                }
                catch (Exception ex)
                {
                    this.CustomerId = 0;
                }

                // Set id on client
                ScriptManager.RegisterStartupScript(this, this.GetType(), "SetEditCustomerId", "SetEditCustomerId('" + this.CustomerId.ToString() + "');", true);

                // Load UI on client
                ScriptManager.RegisterStartupScript(this, this.GetType(), "LoadCustomer", "LoadEditCustomerUserControl('" + this.CustomerId.ToString() + "');", true);

                if (Request.QueryString["Action"] != null)
                {
                    try
                    {
                        // Change UI on client based on preselected action
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "LoadMenuAction", "LoadMenuAction('" + Request.QueryString["Action"].ToString() + "');", true);
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
        }

        public string GetCustomerId() 
        {
            return this.CustomerId.ToString();
        }

    }
}